//
//  Toast.swift
//  YourMusic
//
//  Created by Jarvis on 12/20/16.
//  Copyright © 2016 Jarvis. All rights reserved.
//

import UIKit
import MBProgressHUD

class Toast: NSObject {
    
    class func showMessage(message: String) {
        let hud = MBProgressHUD.showAdded(to: UIApplication.shared.keyWindow!, animated: true)
        hud.mode = .text
        hud.label.text = message
        hud.hide(animated: true, afterDelay: 2)
    }
    
    class func showLoadingOnKeyWindow() {
        MBProgressHUD.showAdded(to: UIApplication.shared.keyWindow!, animated: true)
    }
    
    class func hideLoadingOnKeyWindow() {
        MBProgressHUD.hide(for: UIApplication.shared.keyWindow!, animated: true)
    }
    
    class func hideOnMainThread() {
        DispatchQueue.main.async {
            MBProgressHUD.hide(for: UIApplication.shared.keyWindow!, animated: true)
        }
    }
}
